# -*- encoding: utf-8 -*-
'''
@File		:	baidu.py
@Time		:	2024/01/19 09:32:15
@Author		:	dan
@Description:	该脚本演示使用matter测试百度首页
'''


if __name__ == '__main__':
    import sys
    sys.path.append(".")
import matter
import matter.browser



@matter.test_case(name='搜索')
def search():
    search_input = '//*[@id="kw"]'
    matter.browser.touch_by_xpath(search_input)
    matter.browser.input('今天天气')

    xpath_password = '//*[@id="su"]'
    matter.browser.touch_by_xpath(xpath_password)

    matter.assert_true(message="搜索失败", value=matter.browser.exist_xpath('//*[@id="1"]/div/div/div[1]/div/div[1]/div[2]'))


@matter.test_case(name='点击回车搜索')
def search():
    search_input = '//*[@id="kw"]'
    matter.browser.touch_by_xpath(search_input)
    matter.browser.input('今天天气')
    matter.browser.keyevent(matter.Keys.ENTER)
    matter.assert_true(message="搜索失败", value=matter.browser.exist_xpath('//*[@id="1"]/div/div/div[1]/div/div[1]/div[2]'))


if __name__ == '__main__':
    matter.start(yml='demo/matter/browser/baidu/baidu.yml')